<?php
class BusAction extends LoginAction
{
    public function index ()
    {
        $BusModel = D('Bus');
        $this->assign('bus', $BusModel->getAllData());
        $this->display();
    }
    /**
     * 添加商圈操作
     * @author Ice iceinto@mallog.com.cn
     */
    public function add ()
    {
        if (isPost()) {
            $data = $this->getData();
            $status = $this->createAdd('Bus', $data);
        }
        $this->getOtherData();
        $this->display();
    }
    /**
     * 修改商圈操作
     * @author Ice iceinto@mallog.com.cn
     */
    public function edit ()
    {
        $id = getGetOrPost('id');
        $map = array();
        $map['m_bus.id'] = $id;
        $BusModel = D('Bus');
        $bus = $BusModel->getOnly($map);
        if ($bus) {
            $this->getOtherData();
            $this->assign('bus', $bus);
        } else {
            $this->error('数据传递有错误！');
        }
        if (isPost()) {
            $data = $this->getData();
            $data['db_id'] = $id;
            $status = $this->createUpdate('Bus', $data);
            $bus = $BusModel->getOnly($map);
        }
        $this->display();
    }
    /**
     * 获取其他参数
     * @author Ice iceinto@mallog.com.cn
     */
    public function getOtherData ()
    {
        $ProvinceModel = M('Province');
        $province = $ProvinceModel->select();
        $this->assign('province', $province);
    }
    /**
     * 获取提交数据
     * @author Ice iceinto@mallog.com.cn
     */
    public function getData ()
    {
        $data = array();
        $data['province'] = getPost('province');
        $data['city'] = getPost('city');
        $data['area'] = getPost('area');
        $data['name'] = getPost('busName');
        return $data;
    }
}
?>